home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_01 / saks / rectangl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-07  |  634 b   |  32 lines

  1. Listing 4 - class rectangle derived from shape
  2.  
  3. class rectangle : public shape
  4.     {
  5. public:
  6.     rectangle(palette c, double h, double w);
  7.     double area() const;
  8.     const char *name() const;
  9.     ostream &put(ostream &os) const;
  10. private:
  11.     double height, width;
  12.     };
  13.  
  14. rectangle::rectangle(palette c, double h, double w)
  15.     : shape(c), height(h), width(w) { }
  16.  
  17. double rectangle::area() const
  18.     {
  19.     return height * width;
  20.     }
  21.  
  22. const char *rectangle::name() const
  23.     {
  24.     return "rectangle";
  25.     }
  26.  
  27. ostream &rectangle::put(ostream &os) const
  28.     {
  29.     return shape::put(os) << " with height = " << height
  30.         << " and width = " << width;
  31.     }
  32.